#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int count = 0;
	int a, b, c, d, e, f, g, h, i;
	int num[9] = { 1,2,3,4,5,6,7,8,9 };
	do
	{
		a = num[0];
		b = num[1];
		c = num[2];
		d = num[3];
		e = num[4];
		f = num[5];
		g = num[6];
		h = num[7];
		i = num[8];
		int A = a * 100 + b * 10 + c;
		int B = d * 100 + e * 10 + f;
		int C = g * 100 + h * 10 + i;
		if (A + B == C)
		{
			count++;
		}
	} while (next_permutation(num, num + 9));
	cout << count;
	return 0;
}